package shiyl.use.springboot.loadbalance;

/**
 * 负载点的抽象实现类
 * @author shiyl
 */
public abstract class AbstractLoader<E> implements ILoader{

    boolean available = true ; // endpoint的可用状态，默认可用
    int weight = 0 ;
    boolean sticky =false ;

    public AbstractLoader(int weight , boolean sticky){
       this.weight = weight ;
       this.sticky = sticky ;
    }

    @Override
    public int getWeight() {
        return this.weight;
    }

    public AbstractLoader setWeight( int weight ) {
        this.weight = weight ;
        return this;
    }

    @Override
    public boolean isSticky() {
        return sticky;
    }

    public AbstractLoader setSticky(boolean sticky) {
        this.sticky = sticky ;
        return this;
    }

    @Override
    public boolean isAvailable() {
        return this.available;
    }

    public AbstractLoader setAvailable( boolean abailable) {
        this.available =  abailable ;
        return this;
    }
}
